﻿//裸钻订单
var app_url=location.origin;
var UserID=getcookie("UserID");
var MOBILE=true;
(function () {
    var order = {
        init: function () {
        	TEAM=getUrlParam("team");
            this.bindEvents();
            // var cusOrderList=localStorage.getItem('cusOrderList');
            // if(cusOrderList){
            //     this.getOrder(cusOrderList);
            // }else{
                this.getOrder();
            // }

            this.cusOrderSelect();




            this.CustomerOrderStatusNum();            
        },
        bindEvents: function () {
            var self = this;
            if(APP){
            	$("#OrderStatus").remove();//订单状态统计栏
            	$("#order_term_btn").remove();//订单搜索按钮
            	$("#retr").remove();
            	var h=$(".subnavbar").height()-$("#product_table_fixed").height()-2;
            	$("#app_no_header").css("padding-top",h);
            }else{
            	$("#retr").show();
            	var h=$(".subnavbar").height()+44-$("#product_table_fixed").height()-2;
            	$("#app_no_header").css("padding-top",h);
            }
            
             //导航栏的选中
            $('.wrapper').navbarscroll();
            $("#categories li").eq(0).addClass("cur").siblings().removeClass("cur");
            //订单状态的选中
			$("#OrderStatus span").on("click",function(){
				$(this).addClass("active").siblings().removeClass("active");
				var val=$(this).attr("data-value");//只有待采购可以取消订单
				if(val==1){
					$("#cancel_order_btn").show();
				}else{
					$("#cancel_order_btn").hide();
				}
				self.getOrder();
			});
             //跳转页面
             $("#categories a").on("click",function(){
            	var link_url=$(this).attr("data-href");
//          	if(APP){
//          		var appJson={};
//         			appJson.title=$(this).attr("data-title");
//         			appJson.url=app_url+link_url;	
//         			YiYi_APP.showNewPage(JSON.stringify(appJson));
//          	}else{
            		location.href = link_url;
            	//}
            });
            $("#product_table th").on("click", function () {
                var sort = $(this).children("i");

                if (sort.length > 0) {
                    var iSort = $(this).children("i");
                    var sortName = iSort.attr("data-sort");
                    var sortDirect = iSort.attr("data-sort-direct");
                    if (!sortDirect) {
                        sortDirect = "asc";
                    }
                    else if (sortDirect == "asc") {
                        sortDirect = "desc";
                    }
                    else if (sortDirect == "desc") {
                        sortDirect = "";
                    }

                    iSort.attr("data-sort-direct", sortDirect);
                    iSort.removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
                    iSort.addClass("sort_" + sortDirect);

                    $("th i").not(iSort).removeClass("sort_asc").removeClass("sort_desc").removeClass("sort_normal");
                    $("th i").not(iSort).removeAttr("data-sort-direct");

                    $("th i[data-sort='" + sortName + "']").addClass("sort_" + sortDirect).attr("data-sort-direct", sortDirect);
                    self.getStock();
                }
            });

           //点击详情行关闭
            $("#product_table").on("click", ".stock_detail", function () {
                //$(this).hide();
            });
            //点击行展开详情
            $("#product_table").on("click", "tr.data_tr td", function (event) {
                var td_input = $(this).index();
                if (td_input == 0||td_input == 1) {
                    //勾选框不展开详情
                } else {
                    $(this).parent("tr").next(".stock_detail").slideToggle(0);
                }
            });
            //选中
            $("#product_table").on("click",".check_rel",function(){
				var isChecked=$(this).parent("tr").hasClass("tr_select_color");	
				self.count(isChecked,$(this));				
			});
			$("#product_table").on("click",".check_list_td",function(){				
				$(this).prev().children().find("span").toggleClass("selected");
				var isChecked=$(this).parent("tr").hasClass("tr_select_color");	
				self.count(isChecked,$(this));
			});
			
          	 //取消订单
            $("#cancel_order_btn").on("click", function () {
                var cartlistCb = $("#stock_body .check_list_box span.selected");//tbody中checked的
                if (cartlistCb.length == 0 ) {
                    myApp.alert(_("请选择!"));
                } else {
                    myApp.prompt(_('请在下面输入框说明取消原因'), _('已取消'), function (value) {
			    	if(value!="" && $.trim(value).length != 0){
			    		self.cancelOrder(value);
			    	}else{
			    		 myApp.alert(_('取消原因不能为空！'));
			    	}
			    	//   @*主题色start*@
			       	GetThemesColor();
					//  @*主题色end*@
			    });
                }
            });

           //筛选
            $("#order_term_btn").on("click", function () {
                if(APP){
                	var appJson={};
            		appJson.title=_("订单筛选");
            		appJson.url=app_url+"/Customer/OrderFilter/?type=1";
            		YiYi_APP.showNewPage(JSON.stringify(appJson));
                }else{
                	location.href="/Customer/OrderFilter/?type=1";
                }
            });
            //跳到证书
            $("#stock_body").on("click","a.cert_link_btn",function(){
            	var link_url=$(this).attr("data-href");
            	if(APP){
            		var appJson={};
           			appJson.title=_("证书");
           			appJson.url=app_url+link_url;	
           			YiYi_APP.showNewPage(JSON.stringify(appJson));
            	}else{
            		location.href=link_url;
            	}
            });
			//去掉数组里的空值
			Array.prototype.clean = function(deleteValue) {  
			  for (var i = 0; i < this.length; i++) {  
			    if (this[i] == deleteValue) {           
			      this.splice(i, 1);//返回指定的元素  
			      i--;  
			    }  
			  }  
			  return this;  
			},
			$("#product_table").on("click",".ImageIcon",function(){
            	var params = {};
            	params.InventoryID = $(this).parent().attr("data-value");
            	params.OrderID = $(this).parent().attr("data-id");
            	params.HasImage = 1
            	self.getImages(params);
            });
            
            $("#product_table").on("click",".VideoIcon",function(){
            	var params = {};
            	params.InventoryID = $(this).parent().attr("data-value");
            	params.OrderID = $(this).parent().attr("data-id");
            	params.HasVideo = 1
            	self.getImages(params);
            });


        },
        
        // 获取图片地址
		getImages:function(params){
			var self = this;
			myApp.showIndicator();//显示加载中
			if(TEAM==0){
				var imagesUrl="/Customer/GetImgInfo";//客户端裸钻图片
			}else{
				var imagesUrl="/Team/GetImgInfo";//团队端裸钻图片
			}
            $.ajax({
                url: imagesUrl,//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(params),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                    var _result = eval('(' + result + ')');//eval()解析单个json对象
                    if (_result.msgcode == true) {
                    	myApp.hideIndicator();//隐藏加载中
                    	if(params.HasImage==1){
	                    	var data=_result.msginfo;
							imgs = data.split(",");
							imgArray=[];
					        for (var i=0; i< imgs.length;i++) {
					            if (imgs[i].length > 10) {
					        		var big = imgs[i].replace('800x800', '1920x1920');
					        		imgArray.push(big)
					            }else{
					            	var img_null='/images/no_img.jpg';
					            	imgArray.push(img_null)
					            }
					        }
							 //   @*主题色start*@
			                $(document.createElement("script")).attr("src","/Js/ThemesColor.js").appendTo("html");
							//  @*主题色end*@
							 //放大图片
							var myPhotoBrowserStandalone = myApp.photoBrowser({
							    photos : imgArray,
							    backLinkText: _('返回'),
							    ofText:"/",
							});
							if(APP){
								var ProductImg={};
								ProductImg['images']=imgArray;
								ProductImg['index']=0;
								YiYi_APP.showImages(JSON.stringify(ProductImg));
							}else{	
								myPhotoBrowserStandalone.open();
						    }
                    	}else if(params.HasVideo==1){
                    		var firstImg = _result.msginfo.split(',')[0]; 
							if(APP){
								var ProductVideo={};
								ProductVideo.url = firstImg;
								YiYi_APP.showVideo(JSON.stringify(ProductVideo));
							}else{
								myApp.popup('.popup-services');
		                		var videoHtml=[];
								videoHtml.push(
									'<video src="'+firstImg+'" controls="controls"></video>'
								);
								$(".popup-services #PhotoSwipeTarget").html(videoHtml.join(''));
							}
                    	}
                    } else {
                        myApp.alert(_result.msginfo);
                    }
                    myApp.hideIndicator();//隐藏加载中
                },
		        error: function(XMLHttpRequest, textStatus, errorThrown){
					myApp.alert("网络超时，请重试");
					myApp.hideIndicator();//隐藏加载中
				}
            });
		},
        //统计
        count:function(isChecked,me){
        	var td_rmb=Number(me.attr("data-rmb"));
			var td_usd=Number(me.attr("data-usd"));				
			var choose_num=Number($("#choose_num").text());
			var choose_rmb=Number($("#choose_rmb").text());
			var choose_usd=Number($("#choose_usd").text());				
			if(isChecked){//点击之前是选中 则减少
				me.parent("tr").removeClass("tr_select_color");
				me.children().find("span").removeClass("selected");
				$("#choose_num").text(choose_num-1);
				$("#choose_rmb").text(formatRMBPrice(choose_rmb-td_rmb));
				$("#choose_usd").text(formatUSDPrice(choose_usd-td_usd));
			}else{
				me.children().find("span").addClass("selected");
				me.parent("tr").addClass("tr_select_color");
				$("#choose_num").text(choose_num+1);
				$("#choose_rmb").text(formatRMBPrice(choose_rmb+td_rmb));
				$("#choose_usd").text(formatUSDPrice(choose_usd+td_usd));
			
			}
        },
    	//清除统计
    	clearCount:function(){
    		$("#choose_num").text(0);
			$("#choose_rmb").text(0);
			$("#choose_usd").text(0);
			$("#total_num").text(0);
			$("#total_rmb").text(0);
			$("#total_usd").text(0);			
    	},
        //获取参数
        getQueryParameters: function () {        	       	
            if(PARAMS!=null){
            	// console.log(PARAMS)
				var _orderParams=PARAMS.orderParams;
				//原货号
		 		if(_orderParams.OriginSN!=undefined && _orderParams.OriginSN!=""){
		     		var OriginSNValArray=_orderParams.OriginSN.split(" "); 	
					OriginSNValArray.clean("");
					_orderParams.OriginSN=OriginSNValArray; 
				}
		 		//证书号
		 		// if(_orderParams.CertNo.length!=0){
                 //    if(typeof _orderParams.CertNo!='string'){
                 //        _orderParams.CertNo=_orderParams.CertNo.join('');
                 //    }
				// 	var CertNoValArray=_orderParams.CertNo.split(" ");
				// 	CertNoValArray.clean("");
				// 	_orderParams.CertNo=CertNoValArray;
				// }
                if(_orderParams.CertNo!=undefined && _orderParams.CertNo!=""){
                    var CertNoValArray=_orderParams.CertNo.split(" ");
                    CertNoValArray.clean("");
                    _orderParams.CertNo=CertNoValArray;
                }

            }else{
				var _orderParams={};
				_orderParams.CustomerID = CustomerID;//客户ID
	            _orderParams.PageSize = 100;
	            _orderParams.PageIndex = 1;
	            _orderParams.OrderStatus=0;
			}
			if(APP){//只要待采购可以取消订单
				var val=_orderParams.OrderStatus;
				if(val==1){
					$("#cancel_order_btn").show();
				}else{
					$("#cancel_order_btn").hide();
				}
			}else{
				_orderParams.OrderStatus=$("#OrderStatus span.active").attr("data-value");
			}

			//订单筛选
			//localStorage.setItem('cusOrderList',JSON.stringify(_orderParams));


			return _orderParams;
        },
        //统计订单状态的个数
		CustomerOrderStatusNum:function(){
            var requestOrder = {};
            requestOrder.CustomerID = CustomerID;
            requestOrder.UserID=UserID;
            $.ajax({
                url: "/Team/OrderNumber",//提交地址
                type: "POST",//提交方式
                data: JSON.stringify(requestOrder),
                contentType: "application/json; charset=utf-8",
                success: function (result) {
                    var _result = eval('(' + result + ')');//eval()解析单个json对象
                    var total = 0;
                    if(_result.msgcode== true){
                        _result=_result.msginfo;
                        for (var i = 0; i < _result.length; i++) {
                            if (_result[i].OrderStatus == 1) {//待采购
                                $("#status1").text(_result[i].Number);
                                total += _result[i].Number;
                            }
                            if (_result[i].OrderStatus == 2) {//待到货
                                $("#status2").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            }
                            if (_result[i].OrderStatus == 3) {//待出货
                                $("#status3").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            } 
                            if (_result[i].OrderStatus == 4) {//已出货
                                $("#status4").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            } 
                            if (_result[i].OrderStatus == 5) {//取消成功
                                $("#status5").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            }
                            if (_result[i].OrderStatus == 6) {//退货成功
                                $("#status6").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            }
                            if (_result[i].OrderStatus == 7) {//已退货
                                $("#status7").text(_result[i].Number);//订单
                                total += _result[i].Number;
                            }
                            $("#status0").html(total);//订单总数
                        }
                    }else{
                        $("#status0").text(total);//订单总数
                        $("#status1").text(0);//订单
                        $("#status2").text(0);//订单
                        $("#status3").text(0);//订单
                        $("#status4").text(0);//订单
                        $("#status5").text(0);//订单
                        $("#status6").text(0);//订单
                        $("#status7").text(0);//订单
                    }
                }
            });
        },
       //获取订单
        getOrder: function (data) {
            var self = this;
            self.clearCount();
            myApp.showIndicator();//显示加载中
            var p = self.getQueryParameters();//获取参数
            //获取排序
            var sort = $("th i[data-sort-direct]");
            if (sort.length > 0 && sort.attr("data-sort-direct")) {
                p.SortColumn = sort.attr("data-sort");
                p.SortDirect = sort.attr("data-sort-direct");
            }
            var requestJson = data?data:JSON.stringify(p);
            $.ajax({
                url: "/Customer/GetOrders",
                data: requestJson,
                type: "post",
                contentType: "application/json; charset=utf-8",
                timeout: 30000, //超时时间：30秒
                success: function (result) {
                    var $thead= "<th style='width:7%'>"+_("选中")+"</th>"+
                        "<th style='width:8%'>"+_("重量")+"</th>"+
                        "<th style='width:10%'>"+_("颜色")+"</th>"+
                        " <th style='width:10%'>"+_("净度")+"</th>";
                    if(discount_td==true&&CurrentRMB==true && RMBprice_td==true){
                        $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                        $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                        $thead+="<th style='width:10%'>"+_("对称")+"</th>";
                        $thead+="<th style='width:10%'>"+_("荧光")+"</th>";
                    }else if(discount_td==true&&CurrentUSD==true && USDprice_td==true){
                        $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                        $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                        $thead+="<th style='width:10%'>"+_("对称")+"</th>";
                        $thead+="<th style='width:10%'>"+_("荧光")+"</th>";
                    }else {
                        if(discount_td==true){
                            $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                            $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                            $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                            $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                        }else if(CurrentRMB==true && RMBprice_td==true){
                            $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                            $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                            $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                            $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                        }else {
                            if(CurrentUSD==true && USDprice_td==true){
                                $thead+="<th style='width:10%'>"+_("切工")+"</th>";
                                $thead+="<th style='width:10%'>"+_("抛光")+"</th>";
                                $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                                $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                            }else {
                                $thead+="<th style='width:17%'>"+_("切工")+"</th>";
                                $thead+="<th style='width:18%'>"+_("抛光")+"</th>";
                                $thead+="<th style='width:17%'>"+_("对称")+"</th>";
                                $thead+="<th style='width:18%'>"+_("荧光")+"</th>";
                            }
                        }
                    }


	                    if(discount_td==true){
	                    	$thead+="<th style='width:15%'>"+_("退点")+"</th>";
	                   }
	                   if(CurrentRMB==true && RMBprice_td==true){ //仅美金
		               		$thead+="<th style='width:15%'>"+_("总价 ")+"</th>";
		               	}else{ //全局0和人民币1显示人民币
		               		if(CurrentUSD==true && USDprice_td==true){
		               			$thead+="<th style='width:15%'>"+_("总价 ")+"</th>";
		               		}
		               	}
	                $("#product_table_fixed thead tr,#product_table thead tr").html($thead);         
                    self.bindingInventory(result);//绑定白钻                                    
                    $("body").scrollTop(0);
                    myApp.hideIndicator();//隐藏加载中
                    if(APP){
		        		YiYi_APP.refreshOrderNumber();//重新统计状态数量
		        	}
                },
	            error: function(XMLHttpRequest, textStatus, errorThrown){
					myApp.hideIndicator();//隐藏加载中
					myApp.alert("网络超时，请重试");
				},
            });
        },

        //订单筛选
        cusOrderSelect:function(){
		    var oldData=JSON.parse(localStorage.getItem('cusOrderList'));
		    console.log(oldData)
		   for(var name in oldData){
		       if(name=='OrderStatus'){
		           console.log(oldData[name])
                    $("#product-box").find('#OrderStatus').find('span[data-value="'+oldData[name]+'"]').addClass('active')
               }
           }
        },

        //绑定数据
        bindingInventory: function (result) {
            var _result = JSON.parse(result);//
            var tableTbody = $("#stock_body");
            //获取库存成功
            if (_result["msgcode"] == true) {
 
                if (_result.msginfo.Data.length == 0) {
                    //无结果
                    var tr = "";//单行
                    var tds = "<td colspan='50' style='text-align:center;color:red'>" + _(_result["msginfo"]) + "</td>";// 多列合成一列并居中
                    tr = "<tr>" + tds + "</tr>";//将多列加到一行
                    tableTbody.html(tr);//加入到id为customer的table的tbody中
                } else {
					$("#total_num").text(_result.msginfo.TotalCount);
                    _result = _result.msginfo.Data;//object   
                    
                    stock_json = _result;

                    $("#easy_js").html('<script src="/Js/jquery.easyui.min.js"></script>');
                    var trs = "";//多行数据
					var total_rmb=0;
					var total_usd=0;
                    for (var i = 0; i < _result.length; i++) {

                        var tds = "";//多列
                        var tr = "";//单行
                        var tr_div = "";
                        var data=_result[i];
                        tds += "<td class='check_rel' data-rmb="+formatRMBPrice(data.ConfirmPrice)+" data-usd="+formatUSDPrice(data.ConfirmUSD)+">"+
                        "<div class='check_list_box'><span class='checkbox' data-status='"+data.OrderStatus+"' name='checkbox' lang='" + data.OrderID + "'></span></div>";
                        "<div style='display:none' class='check_list_box'><span class='checkbox' data-status='"+data.OrderStatus+"' name='checkbox' lang='" + data.OrderID + "'></span></div>";
//                      "<input type='checkbox' value='check[i]' name='checkbox' lang='" + data.OrderID + "'/><div class='checkbox_fu'></div></td>";
                        tds += "<td class='check_list_td' data-rmb="+formatUSDPrice(data.ConfirmPrice)+" data-usd="+formatUSDPrice(data.ConfirmUSD)+">" + data.Weight + "</td>";
                        tds += "<td>" + ColorFormat(data.Color) + "</td>";
                        tds += "<td>" + data.Clarity + "</td>";
                        tds += "<td>" + data.Cut + "</td>";
                        tds += "<td>" + data.Polish + "</td>";
                        tds += "<td>" + data.Symmetry + "</td>";
                        tds += "<td>" + data.Fluorescence + "</td>";
                        if(data.IsFancy==0 && discount_td==true){
                        	 tds += "<td>" + ValueFormat(data.Confirmdiscount) + "</td>";
                        }else{
                            tds += "<td></td>";
                        }
                        if(CurrentRMB==true && RMBprice_td==true){ //人民币
		               		tds += "<td style='font-weight:bold'>" + formatRMBPrice(data.ConfirmPrice)  + "</td>";//四舍五入
		               }else{ //全局0和人民币1显示美金
		               		if(CurrentUSD==true && USDprice_td==true){
		               			tds += "<td style='font-weight:bold'>" +formatUSDPrice(data.ConfirmUSD) + "</td>";//四舍五入
		               		}
		               }
                        tr += "<tr class='data_tr'>" + tds + "</tr>";//将多列加到一行
                        tr_div = "<tr class='stock_detail'><td  colspan='50'>"+
                        "<div class='detail_left' style='width:50%;'>";
                        if(OriginSN_td==true){
                        	tr_div +="<i onclick='showTotalWord(this)'><b class='custrom'>"+_("原货号")+"：</b><span>" + data.OriginSN + "</span></i>";
                        }
                        if(SN_td==true){
                            tr_div +="<i onclick='showTotalWord(this)'><b class='custrom'>"+_("货号")+"：</b><span>" + data.SN + "</span></i>";
                        }
                        	tr_div +="<i><b>"+_("形状")+"：</b>" + GetText("stocks",1,data.Shape,"Shape") + "</i>" +
                        	"<i><b>"+_("状态")+"：</b>" + GetText("stocks",1,data.Status,"Status") + "</i>" +
                        	"<i><b>"+_("奶油")+"：</b>" + MilkyFormat(data.Milky) + "</i>"+
                        	"<i><b>"+_("色调")+"：</b>" + HueFormat(data.Hue) + "</i>"+
                        	"<i><b>"+_("心箭")+"：</b>" + HAFormat(data.HA) + "</i>"+
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("黑点")+"：</b><span>" + BlackDefectFormat(data.BlackDefect) + "</span></i>" +
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("瑕疵")+"：</b><span>" + OtherDefectFormat(data.OtherDefect) + "</span></i>"+
                        	"<i onclick='showTotalWord(this)'><b class='custrom'>"+_("尺寸")+"：</b><span>" + data.Measurement + "</span></i>";
                        	if(cert_td==true && certNo_td==true){
                        		tr_div +="<i><b>"+_("证书")+"：</b>" + CertTypeFormat(data) + "</i>";
                        	}else if(cert_td==true){
                        		tr_div +="<i><b>"+_("证书")+"：</b>" + data.CertType + "</i>";
                        	}
                        	if(certNo_td==true){
                        		tr_div +="<i onclick='showTotalWord(this)'><b class='custrom'>"+_("证书号")+"：</b><span>" + NullFormat(data.CertNo) + "</span></i>";
                        	}
                        	if(place_td==true){
                        		tr_div +="<i><b>"+_("所在地")+"：</b>" + GetText("stocks",1,data.Place,"Place") + "</i>";
                        	}
                        tr_div +="</div>" +
                       "<div class='detail_right' style='width:50%;'>"+                       		
                       		"<i class='exchangeRate'><b>"+_("汇率")+"：</b>" + data.SalesExchangerate + "</i>";
                       		if(rap_td==true){
                        		tr_div +="<i><b>"+_("Rap")+"：</b>" + data.Rapnet + "</i>";
                        	}
                       		if(CurrentUSD==true && USDprice_td==true){
                        		tr_div +="<i class='CurrentUSD'><b>$/Pcs：</b>" + formatUSDPrice(data.ConfirmUSD) + "</i>";
                        		total_usd+=formatUSDPrice(data.ConfirmUSD);
                        	}
                       		if(CurrentRMB==true && RMBprice_td==true){
                        		tr_div +="<i class='CurrentRMB'><b>￥/Pcs：</b>" + formatRMBPrice(data.ConfirmPrice) + "</i>";
                        		total_rmb+=formatRMBPrice(data.ConfirmPrice);
                        	}
                        	tr_div +="<i><b>"+_("客户")+"：</b>" + data.CustomerNickName + "</i>"+
                        	"<i><b>"+_("订单状态")+"：</b>" + CustomerOrderStatusFormat(data.OrderStatus) + "</i>" +
                        	"<i><b>"+_("支付")+"：</b>" + PaymentStatusFormat(data.PaymentStatus) + "</i>" +                       	
                        	"<i><b>"+_("下单")+"：</b>" + DateTimeFormat(data.CreateTime) + "</i>" +
                        	"<i><b>"+_("发货")+"：</b>" + DateFormat(data.DeliveryTime) + "</i>" +
                        	"<i><b>"+_("出货")+"：</b>" +DateFormat(data.ShipTime) + "</i>" +
                        	"<i><b>"+_("到货")+"：</b>" +DateFormat(data.ArrivalTime) + "</i>" +
                        	"<i '><b class='custrom'>"+_("备注")+"：</b><span>" + data.Remarks + "</span></i>"+  
                        	"<i data-value = '"+data.InventoryID+"' data-id='"+data.OrderID+"'><b>"+_("图片")+"：</b>" + GetImgHd(data) + "</i>"+
                        "</div>"+
                        "</td></tr>";                                                
                        trs += tr + tr_div;//将单行加到多行
                    }
                    tableTbody.html(trs);//加入到id为customer的table的tbody中
                    //统计
                    if(CurrentUSD==true && USDprice_td==true){
                    	$("#total_usd_box").html(_("共")+'$<i id="total_usd">'+formatUSDPrice(total_usd)+'</i>');
                    	$("#choose_usd_box").html(_("选中")+'$<i id="choose_usd">0</i>');
                    }
                    if(CurrentRMB==true && RMBprice_td==true){
                    	$("#total_usd_box").html(_("共")+'￥<i id="total_rmb">'+formatRMBPrice(total_rmb)+'</i>');
                    	$("#choose_rmb_box").html(_("选中")+'￥<i id="choose_rmb">0</i>');
                    }
                    currentShow();  //币种设置
                }

            } else {
                //获取库存失败
                var tr = "";//单行
                var tds = "<td colspan='50' style='text-align:center;color:red'>" + _(_result["msginfo"]) + "</td>";// 多列合成一列并居中
                tr = "<tr>" + tds + "</tr>";//将多列加到一行
                tableTbody.html(tr);//加入到id为customer的table的tbody中
            }
            copyHeader("product_table", "tab_head");//复制表头

        },

        //取消订单
        cancelOrder: function (remarks) {
        	var self=this;
            var requestOrder = {};
            var cartlistCb = $("#stock_body .check_list_box span.selected");//tbody中checked的
            var _inventoryIDs = "";
            for (var i = 0; i < cartlistCb.length; i++) {
                if (i == 0)
                    _inventoryIDs += cartlistCb[i].lang;
                else
                    _inventoryIDs += "," + cartlistCb[i].lang;
            }

            requestOrder.OrderIDs = _inventoryIDs;
            requestOrder.CustomerID = CustomerID;
            requestOrder.OrderType = "1";
            requestOrder.Remarks = remarks;
                $.ajax({
                    url: "/Customer/CancelOrders",//提交地址
                    type: "POST",//提交方式
                    data: JSON.stringify(requestOrder),
                    contentType: "application/json; charset=utf-8",
                    success: function (result) {
                        $("#disOder_remarks").hide();
                        var _result = eval('(' + result + ')');//eval()解析单个json对象
                        if (_result.msgcode == true) {
                        	self.CustomerOrderStatusNum();                        	
                            myApp.alert(_("成功取消订单!"),function(){
                            	self.getOrder();
                            	if(APP){
					        		YiYi_APP.refreshOrderNumber();//重新统计装态数量
					        	}
                            });
                        } else {
                            myApp.alert(_("订单取消失败!"));
                        }

                    }
                });

        },

    }

   order.init();
}());


// 获取图片和视频
function GetImgHd(data){
	var str = "";
	if(data.HasImage==1){
        str +='<img alt="图片" src="/images/imageIcon.png" class="ImageIcon" />';
    }
	if(data.HasVideo==1){
		str+='<img alt="视频" src="/images/videoIcon.png" class="VideoIcon" />'
	}
	return str;
}
